﻿using AutoMapper;
using RoutineApi.Entities;
using RoutineApi.Models;
using System;

namespace RoutineApi.Profiles
{
    public class EmployeeProfile : Profile
    {
        public EmployeeProfile()
        {
            CreateMap<Employee, EmployeeDto>()
                .ForMember(dest => dest.Name, opt => opt.MapFrom(scr => $"{scr.FirstName}  {scr.LastName}"))
                .ForMember(dest => dest.GenderDisPlay, opt => opt.MapFrom(scr => scr.Gender.ToString()))
                .ForMember(dest => dest.Age, opt => opt.MapFrom(scr => DateTime.Now.Year - scr.DateOfBirth.Year));
        }
    }
}
